package com.ep.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ep.common.utils.PageUtils;
import com.ep.modules.app.dao.AppInternalDataSourceMapper;
import com.ep.modules.app.entity.AppInternalDataSource;
import com.ep.modules.app.entity.AppInternalDataSourceExample;
import com.ep.modules.app.service.AppInternalDataSourceService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppInternalDataSourceServiceImpl implements AppInternalDataSourceService {
    @Autowired
    private AppInternalDataSourceMapper appInternalDataSourceMapper;

    public PageUtils queryPage(Map<String, Object> params) {
        String searchKey = (String)params.get("searchKey");
        Long searchUserId = (Long)params.get("searchUserId");
        AppInternalDataSourceExample example = new AppInternalDataSourceExample();
        AppInternalDataSourceExample.Criteria criteria = example.createCriteria();
        List<AppInternalDataSource> list = appInternalDataSourceMapper.selectByExample(example);
        Page<AppInternalDataSource> page = new Page<>();
        page.setRecords(list);
        return new PageUtils(page);
    }

    public AppInternalDataSource getById(Long id) {
        return appInternalDataSourceMapper.selectByPrimaryKey(id.intValue());
    }

    public void save(AppInternalDataSource entity) {
        appInternalDataSourceMapper.insert(entity);
    }

    public void update(AppInternalDataSource entity) {
        appInternalDataSourceMapper.updateByPrimaryKeySelective(entity);
    }

    public void deleteBatch(Long[] ids) {
        for (Long id : ids) {
                appInternalDataSourceMapper.deleteByPrimaryKey(id.intValue());
        }
    }
}